import {defHttp} from '/@/utils/http/axios';
import { useMessage } from "/@/hooks/web/useMessage";

const { createConfirm } = useMessage();

enum Api {
  listInHalfMonth = '/assets.leaseContract/dbHtb/listInHalfMonth',
  list = '/assets.leaseContract/dbHtb/list',
  save='/assets.leaseContract/dbHtb/add',
  edit='/assets.leaseContract/dbHtb/edit',
  deleteOne = '/assets.leaseContract/dbHtb/delete',
  deleteBatch = '/assets.leaseContract/dbHtb/deleteBatch',
  importExcel = '/assets.leaseContract/dbHtb/importExcel',
  exportXls = '/assets.leaseContract/dbHtb/exportXls',
  dbTtfkList = '/assets.leaseContract/dbHtb/listDbTtfkByMainId',
  dbTtfkSave='/assets.leaseContract/dbHtb/addDbTtfk',
  dbTtfkEdit='/assets.leaseContract/dbHtb/editDbTtfk',
  dbTtfkDelete = '/assets.leaseContract/dbHtb/deleteDbTtfk',
  dbTtfkDeleteBatch = '/assets.leaseContract/dbHtb/deleteBatchDbTtfk',
  dbTtgmbList = '/assets.leaseContract/dbHtb/listDbTtgmbByMainId',
  dbTtgmbSave='/assets.leaseContract/dbHtb/addDbTtgmb',
  dbTtgmbEdit='/assets.leaseContract/dbHtb/editDbTtgmb',
  dbTtgmbDelete = '/assets.leaseContract/dbHtb/deleteDbTtgmb',
  dbTtgmbDeleteBatch = '/assets.leaseContract/dbHtb/deleteBatchDbTtgmb',
  dbGlfb1List = '/assets.leaseContract/dbHtb/listDbGlfb1ByMainId',
  dbGlfb1Save='/assets.leaseContract/dbHtb/addDbGlfb1',
  dbGlfb1Edit='/assets.leaseContract/dbHtb/editDbGlfb1',
  dbGlfb1Delete = '/assets.leaseContract/dbHtb/deleteDbGlfb1',
  dbGlfb1DeleteBatch = '/assets.leaseContract/dbHtb/deleteBatchDbGlfb1',
  dbCfzjbList = '/assets.leaseContract/dbHtb/listDbCfzjbByMainId',
  dbCfzjbSave='/assets.leaseContract/dbHtb/addDbCfzjb',
  dbCfzjbEdit='/assets.leaseContract/dbHtb/editDbCfzjb',
  dbCfzjbDelete = '/assets.leaseContract/dbHtb/deleteDbCfzjb',
  dbCfzjbDeleteBatch = '/assets.leaseContract/dbHtb/deleteBatchDbCfzjb',
}
export const api = Api;
/**
 * 导出api
 * @param params
 */
export const getExportUrl = Api.exportXls;

/**
 * 导入api
 */
export const getImportUrl = Api.importExcel;
/**
 * 列表接口
 * @param params
 */
export const list = (params) =>
  defHttp.get({url: Api.list, params});




const getDatestr = (datetime)=>{
  let date = datetime.getFullYear()+"-"+(datetime.getMonth()+1)+"-"
  let d =  datetime.getDate();
  let d1 = "";
  if(d<10){
    d1 = "0"+d;
  } else{
    d1 = ""+d;
  }
  date = date+d1;
  return date;
};

export const listInHalfMonth = ()=>{
/*  let date = getDatestr(new Date());

  let date1 = new Date();
  let dates = date1.setDate(date1.getDate()-15);
  date1 = new Date(dates);
  console.log(date1.toLocaleString());
  let date2 = getDatestr(date1);*/
  //let params = {qyrq_begin:date2,qyrq_end:date}
  let params  = {};
  return defHttp.get({url: Api.listInHalfMonth, params});
};


/**
 * 删除单个
 */
export const deleteOne = (params,handleSuccess) => {
  return defHttp.delete({url: Api.deleteOne, params}, {joinParamsToUrl: true}).then(() => {
    handleSuccess();
  });
}
/**
 * 批量删除
 * @param params
 */
export const batchDelete = (params, handleSuccess) => {
  createConfirm({
    iconType: 'warning',
    title: '确认删除',
    content: '是否删除选中数据',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      return defHttp.delete({url: Api.deleteBatch, data: params}, {joinParamsToUrl: true}).then(() => {
        handleSuccess();
      });
    }
  });
}
/**
 * 保存或者更新
 * @param params
 */
export const saveOrUpdate = (params, isUpdate) => {
  let url = isUpdate ? Api.edit : Api.save;
  return defHttp.post({url: url, params});
}
/**
 * 列表接口
 * @param params
 */
export const dbTtfkList = (params) => {
  if(params['ph']){
    return defHttp.get({url: Api.dbTtfkList, params});
  }
  return Promise.resolve({});
}


/**
 * 删除单个
 */
export const dbTtfkDelete = (params,handleSuccess) => {
  return defHttp.delete({url: Api.dbTtfkDelete, params}, {joinParamsToUrl: true}).then(() => {
    handleSuccess();
  });
}
/**
 * 批量删除
 * @param params
 */
export const dbTtfkDeleteBatch = (params, handleSuccess) => {
  createConfirm({
    iconType: 'warning',
    title: '确认删除',
    content: '是否删除选中数据',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      return defHttp.delete({url: Api.dbTtfkDeleteBatch, data: params}, {joinParamsToUrl: true}).then(() => {
        handleSuccess();
      });
    }
  });
}
/**
 * 保存或者更新
 * @param params
 */
export const  dbTtfkSaveOrUpdate = (params, isUpdate) => {
  let url = isUpdate ? Api.dbTtfkEdit : Api.dbTtfkSave;
  return defHttp.post({url: url, params});
}
/**
 * 导入
 */
export const dbTtfkImportUrl = '/assets.leaseContract/dbHtb/importDbTtfk'

/**
 * 导出
 */
export const dbTtfkExportXlsUrl = '/assets.leaseContract/dbHtb/exportDbTtfk'
/**
 * 列表接口
 * @param params
 */
export const dbTtgmbList = (params) => {
  if(params['ph']){
    return defHttp.get({url: Api.dbTtgmbList, params});
  }
  return Promise.resolve({});
}


/**
 * 删除单个
 */
export const dbTtgmbDelete = (params,handleSuccess) => {
  return defHttp.delete({url: Api.dbTtgmbDelete, params}, {joinParamsToUrl: true}).then(() => {
    handleSuccess();
  });
}
/**
 * 批量删除
 * @param params
 */
export const dbTtgmbDeleteBatch = (params, handleSuccess) => {
  createConfirm({
    iconType: 'warning',
    title: '确认删除',
    content: '是否删除选中数据',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      return defHttp.delete({url: Api.dbTtgmbDeleteBatch, data: params}, {joinParamsToUrl: true}).then(() => {
        handleSuccess();
      });
    }
  });
}
/**
 * 保存或者更新
 * @param params
 */
export const  dbTtgmbSaveOrUpdate = (params, isUpdate) => {
  let url = isUpdate ? Api.dbTtgmbEdit : Api.dbTtgmbSave;
  return defHttp.post({url: url, params});
}
/**
 * 导入
 */
export const dbTtgmbImportUrl = '/assets.leaseContract/dbHtb/importDbTtgmb'

/**
 * 导出
 */
export const dbTtgmbExportXlsUrl = '/assets.leaseContract/dbHtb/exportDbTtgmb'
/**
 * 列表接口
 * @param params
 */
export const dbGlfb1List = (params) => {
  if(params['ph']){
    return defHttp.get({url: Api.dbGlfb1List, params});
  }
  return Promise.resolve({});
}


/**
 * 删除单个
 */
export const dbGlfb1Delete = (params,handleSuccess) => {
  return defHttp.delete({url: Api.dbGlfb1Delete, params}, {joinParamsToUrl: true}).then(() => {
    handleSuccess();
  });
}
/**
 * 批量删除
 * @param params
 */
export const dbGlfb1DeleteBatch = (params, handleSuccess) => {
  createConfirm({
    iconType: 'warning',
    title: '确认删除',
    content: '是否删除选中数据',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      return defHttp.delete({url: Api.dbGlfb1DeleteBatch, data: params}, {joinParamsToUrl: true}).then(() => {
        handleSuccess();
      });
    }
  });
}
/**
 * 保存或者更新
 * @param params
 */
export const  dbGlfb1SaveOrUpdate = (params, isUpdate) => {
  let url = isUpdate ? Api.dbGlfb1Edit : Api.dbGlfb1Save;
  return defHttp.post({url: url, params});
}
/**
 * 导入
 */
export const dbGlfb1ImportUrl = '/assets.leaseContract/dbHtb/importdbGlfb1'

/**
 * 导出
 */
export const dbGlfb1ExportXlsUrl = '/assets.leaseContract/dbHtb/exportdbGlfb1'



/**
 * 列表接口
 * @param params
 */
export const dbCfzjbList = (params) => {
  if(params['ph']){
    return defHttp.get({url: Api.dbCfzjbList, params});
  }
  return Promise.resolve({});
}


/**
 * 删除单个
 */
export const dbCfzjbDelete = (params,handleSuccess) => {
  return defHttp.delete({url: Api.dbCfzjbDelete, params}, {joinParamsToUrl: true}).then(() => {
    handleSuccess();
  });
}
/**
 * 批量删除
 * @param params
 */
export const dbCfzjbDeleteBatch = (params, handleSuccess) => {
  createConfirm({
    iconType: 'warning',
    title: '确认删除',
    content: '是否删除选中数据',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      return defHttp.delete({url: Api.dbCfzjbDeleteBatch, data: params}, {joinParamsToUrl: true}).then(() => {
        handleSuccess();
      });
    }
  });
}
/**
 * 保存或者更新
 * @param params
 */
export const  dbCfzjbSaveOrUpdate = (params, isUpdate) => {
  let url = isUpdate ? Api.dbCfzjbEdit : Api.dbCfzjbSave;
  return defHttp.post({url: url, params});
}
/**
 * 导入
 */
export const dbCfzjbImportUrl = '/assets.leaseContract/dbHtb/importDbCfzjb'

/**
 * 导出
 */
export const dbCfzjbExportXlsUrl = '/assets.leaseContract/dbHtb/exportDbCfzjb'
